package com.zsummer.zero.jdk.jvm;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Demo1 {
	
	public static void main(String[] args) {
		try {
			//Class<?> clazz = Class.forName("com.zsummer.baikal.test.Demo2");
			Class<?> clazz = Demo1.class.getClassLoader().loadClass("com.zsummer.baikal.test.Demo2");
			Method method = clazz.getMethod("sayHello");
			Object newInstance = clazz.getConstructor().newInstance();
			Object invoke = method.invoke(newInstance);
			System.out.println(invoke);
			
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
